/*
 * @Author: ziqi jhzq12345678
 * @Date: 2024-08-19 21:20:47
 * @LastEditors: wangdazhuang
 * @LastEditTime: 2024-11-02 09:25:58
 * @FilePath: /pornhub_app/lib/src/views/search/search_controller.dart
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import 'package:pornhub_app/services/storage_service.dart';
import 'package:get/get.dart';

class SearchUserPageController extends GetxController {
  final service = Get.find<StorageService>();
  var history = [].obs;
  var keyWord = ''.obs;
  var user_id = 0.obs;
  var nums = [0, 0, 0, 0].obs;
  void addHistory(String v, {int uid = 0}) {
    keyWord.value = v;
    user_id.value = uid;
    // if (!history.contains(v)) {
    //   history.insert(0, v);
    //   service.setHistory(v);
    // }
  }

  @override
  void onInit() {
    history.value = service.history;
    if (Get.arguments is Map) {
      {
        int uid = Get.arguments["user_id"] ?? 0;
        if (uid != 0) {
          user_id.value = uid;
          // keyWord.value = "";
        }
      }
    }

    super.onInit();
  }

  void clearHistory() {
    history.value = [];
    service.deleteHistory();
  }

  void changeNums(List<int> v) {
    nums.value = v;
  }
}
